from tqdm import tqdm
from threading import Thread
import itertools
import string
import time


def worker(items, total):
    # print(total)
    for item in tqdm(items, total=total):
        # 模拟耗时的计算任务
        time.sleep(0.1)


def main():
    threads = 512
    password_length = 3
    #password_types = ['ascii_letters', 'digits', 'punctuation']
    password_types = ['ascii_letters', 'digits']
    characters = "".join([getattr(string, k) for k in password_types])
    # string.ascii_letters + string.digits + string.punctuation
    print(characters)
    password_combinations = itertools.product(characters, repeat=password_length)
    thread = Thread(target=worker, args=(password_combinations, len(characters)**password_length))
    thread.start()
    thread.join()  # 等待线程完成


if __name__ == "__main__":
    main()